package com.gqz.controller.common;

import com.gqz.service.IFileService;
import com.gqz.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/blog/file")
public class FileController {

    @Autowired
    private IFileService fileService;

    @PostMapping("/upload")
    public JsonResult upload(MultipartFile file) {
        String result = fileService.upload(file);
        return result == null ? JsonResult.fail("上传失败!") : JsonResult.ok(result);
    }
}
